<template>
  <header class="simple-title-bar">
    <!-- Left Section -->
    <div class="title-bar__left">
      <!-- Chat Info -->
      <div class="chat-info">
        <h1 class="chat-title">{{ chatTitle }}</h1>
        <div class="client-info">
          <span class="client-name">{{ clientName }}</span>
          <span
            v-if="onlineStatus"
            class="online-indicator online-indicator--active"
          >
            <span class="status-dot"></span>
            在线
          </span>
        </div>
      </div>
    </div>
    
    <!-- Right Section -->
    <div class="title-bar__right">
      <!-- Action Buttons -->
      <div class="action-buttons">
        <button
          v-for="action in actions"
          :key="action.id"
          @click="action.onClick"
          class="action-button"
          :title="action.label"
        >
          <span class="icon">{{ getActionIcon(action.icon) }}</span>
          <span class="label">{{ action.label }}</span>
        </button>
      </div>
    </div>
  </header>
</template>

<script setup>
// Props
const props = defineProps({
  chatTitle: {
    type: String,
    default: ''
  },
  clientName: {
    type: String,
    default: ''
  },
  onlineStatus: {
    type: Boolean,
    default: false
  },
  actions: {
    type: Array,
    default: () => []
  }
})

// Methods
const getActionIcon = (iconName) => {
  const icons = {
    info: 'ℹ️',
    search: '🔍',
    more: '⋯',
    phone: '📞',
    video: '📹',
    settings: '⚙️',
    close: '✕'
  }
  return icons[iconName] || '•'
}
</script>

<style scoped>
.simple-title-bar {
  height: 64px;
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 10;
}

/* Left Section */
.title-bar__left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.chat-info {
  flex: 1;
  min-width: 0;
}

.chat-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0 0 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.client-name {
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.online-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #999;
  font-size: 12px;
}

.online-indicator--active {
  color: #52c41a;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Right Section */
.title-bar__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.action-button {
  padding: 6px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  background: #fff;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  transition: all 0.2s;
}

.action-button:hover {
  background: #f5f5f5;
  border-color: #1890ff;
  color: #1890ff;
}

.action-button .icon {
  font-size: 14px;
}

.action-button .label {
  font-weight: 500;
}

/* 响应式 */
@media (max-width: 768px) {
  .simple-title-bar {
    padding: 0 16px;
  }
  
  .chat-title {
    font-size: 16px;
  }
  
  .client-info {
    font-size: 12px;
  }
  
  .action-button .label {
    display: none;
  }
  
  .action-button {
    padding: 6px 8px;
  }
}
</style>